home *** CD-ROM | disk | FTP | other *** search
/ Internet Surfer 2.0 / Internet Surfer 2.0 (Wayzata Technology) (1996).iso / pc / textfile / faqs / x_faq / part4 < prev    next >
Encoding:
Internet Message Format  |  1992-12-27  |  50.2 KB

  1. Xref: bloom-picayune.mit.edu comp.windows.x:61857 news.answers:4490
  2. Newsgroups: comp.windows.x,news.answers
  3. Path: bloom-picayune.mit.edu!enterpoop.mit.edu!eff!sol.ctr.columbia.edu!caen!uunet!visual!dbl
  4. From: dbl@visual.com (David B. Lewis)
  5. Subject: comp.windows.x Frequently Asked Questions (FAQ) 4/4
  6. Message-ID: <1992Dec8.145405.7635@visual.com>
  7. Followup-To: poster
  8. Summary: useful information about the X Window System
  9. Reply-To: faq%craft@uunet.uu.net (X FAQ maintenance address)
  10. Organization: Visual
  11. Date: Tue, 8 Dec 92 14:54:05 GMT
  12. Approved: news-answers-request@MIT.Edu
  13. Expires: Sun, 03 Jan 1993 00:00:00 GMT
  14. Lines: 1043
  15.  
  16. Archive-name: x-faq/part4
  17. Last-modified: 1992/12/07
  18.  
  19. ----------------------------------------------------------------------
  20. Subject: 107)  What are these problems with "_XtInherit not found" on the Sun?
  21. When I run a X program that I wrote on a SunOS 4.0.3 or 4.1 machine I get the 
  22. error "ld.so: symbol not found _XtInherit".
  23.  
  24.     What you are seeing is a side-effect of a kludge in the R4 libXt.a to 
  25. get Sun shared libraries working.  Apparently, you can't share a function that 
  26. is both called and compared, as _XtInherit is. This was handled by putting 
  27. _XtInherit in the same file as a function that is always used, thereby 
  28. guaranteeing that it would be loaded -- that is, in Initialize.c, where 
  29. XtToolkitInitialize() and XtInitialize() reside. These routines would normally
  30. be called.
  31.  
  32.     You are probably seeing this error because your program is not a normal
  33. Xt-based program and does not call XtToolkitInitialize() anywhere. 
  34.     1) it may be a program that uses Xt functions but never opens a 
  35. connection to the X server.  [OSF/Motif's 1.1.0 UIL had this problem; it called
  36. XtMalloc() and other Xt functions.] The solution is to add the call to your 
  37. program; the function does not have to be executed, just linked in.
  38.     2) alternatively, your program doesn't need any Xt functions and is
  39. correct in not calling XtToolkitInitialize() -- it may be an Xlib or XView 
  40. program. In this case, you can remove -lXt from your link command. 
  41.  
  42.     It should not be necessary to link the shared libraries statically,
  43. although this will certainly solve the problem.
  44.     
  45. [from Jordan Hayes (now jordan@MooreNet.COM) and Danny Backx (db@sunbim.be); 
  46. 11/90]
  47.  
  48. ----------------------------------------------------------------------
  49. Subject: 108)  Why can't I compile my R3 Xaw contrib programs under the new X?
  50. I have a program that worked well under X11R3. When I try to link it under 
  51. the current version of X, I get this message:
  52.     Undefined:
  53.     _XtScrollBarSetThumb
  54.     _XtTextSetInsertionPoint
  55.     _XtTextReplace
  56.  
  57.     There were several name changes in the Athena widget set (in addition
  58. to the header files moving into <X11/Xaw/>); these are mentioned in the R4
  59. release notes. In this case, these functions are not really Xt functions but
  60. are part of the Xaw text widget and so have been renamed from Xt* to Xaw*.
  61. [10/90]
  62.  
  63. ----------------------------------------------------------------------
  64. Subject: 109)  TOPIC: PROGRAMMING PROBLEMS AND PUZZLES
  65. ----------------------------------------------------------------------
  66. Subject: 110)  Why doesn't my program get the keystrokes I select for (sic)?
  67.  
  68.     The window manager controls how the input focus is transferred from one
  69. window to another.  In order to get keystrokes, your program must ask the
  70. window manager for the input focus.  To do this, you must set up what are
  71. called "hints" for the window manager.  If your applications is Xlib-based, you
  72. can use something like the following:
  73.  
  74.         XWMHints wmhints;
  75.         ...
  76.         wmhints.flags = InputHint;
  77.         wmhints.input = True;
  78.         XSetWMHints(dpy, window, &wmhints)
  79.  
  80. If your application is based on the Xt Intrinsics, you can set the XtNinput 
  81. resource to be True (as you probably want to in any case); if you don't have
  82. source, you can start up the application with the resource '*input:True'.
  83.  
  84. Certain window managers, notably dxwm and olwm, are very picky about having 
  85. this done. 
  86.  
  87.     If you are using Sun's OpenWindows olwm, you can also add this resource
  88. to your defaults file to use clients that aren't ICCCM-compliant.
  89.     OpenWindows.FocusLenience:       true
  90.  
  91. [mostly courtesy Dave Lemke of NCD and Stuart Marks of Sun]
  92.  
  93. ----------------------------------------------------------------------
  94. Subject: 111)  How do I figure out what window manager is running?
  95.  
  96.     You can't reliably tell; whatever mechanism you could use could be
  97. spoofed in any case. 
  98.     For most cases, you shouldn't care which window manager is running, so 
  99. long as you do things in an ICCCM-conformant manner. There are some cases in 
  100. which particular window managers are known to do things wrong; checking for
  101. particular hints placed on the window by the window manager so that you can 
  102. sidestep the problem may be appropriate in these cases. Alternatively, it may 
  103. be appropriate to determine which window manager is running in order to take
  104. advantage of specific *added* features (such as olwm's push-pin menus) in order
  105. to give your program *added* functionality. Beware of usurping the window 
  106. manager's functions by providing that functionality even when it is missing;
  107. this surely leads to future compatibility problems.
  108.  
  109. ----------------------------------------------------------------------
  110. Subject: 112)  Is there a skeleton X program available?
  111.     
  112.     There is no general framework such as the TransSkel program for the 
  113. Macintosh which handles lots of the odds and ends and overhead of development 
  114. under a window system and which can be used as a platform for additional 
  115. development. In X, the problem is typically solved by using an interactive 
  116. application builder tool or by using cut&paste on existing X applications. Good
  117. applications which you might look to manipulate when you want to "test just 
  118. this one little thing" include contrib/clients/xskel, a simple R4 program that 
  119. puts up a window and allows sketching in it and offers a starting point for
  120. quick hacks, the Xaw examples in the examples/ directory in the R3 and R4 
  121. distributions, and the Xlib "Hello World" example in the R3 doc/HelloWorld and 
  122. R4 doc/tutorials/HelloWorld; an updated version of this program which uses R4 
  123. Xlib calls and current ICCCM conventions was posted in 2/90 to comp.windows.x  
  124. by Glenn Widener of Tektronix.     [3/90]
  125.  
  126.     In addition, a sample Xt program (for Xaw or Xm) by Rainer Klute 
  127. showing how to open multiple displays and how to catch a broken display 
  128. connection is available on export.lcs.mit.edu in contrib/mdisp.tar.Z. [4/92]
  129.  
  130. ----------------------------------------------------------------------
  131. Subject: 113)  Why does XtGetValues not work for me (sic)?
  132.  
  133.     The XtGetValues interface for retrieving resources from a widget is
  134. sensitive to the type of variable. Your code may be doing something like this:
  135.     {
  136.     Arg args[3];
  137.     int i;
  138.     int sensitive;        /* oops; wrong data type */
  139.     i=0;
  140.     XtSetArg (args[i], XtNsensitive, &sensitive); i++;
  141.     XtGetValues(widget, args, i );
  142.     ...
  143.     }
  144.  
  145. But XtNsensitive is a Boolean, which on most machines is a single byte; 
  146. declaring the variable "sensitive" as Boolean works properly. This problem 
  147. comes up often when using particular toolkits that redefine the Xt types 
  148. Dimension and Position; code that assumes they are int will have similar 
  149. problems if those types are actually short. In general: you are safe if you
  150. use the actual type of the resource, as it appears in the widget's man page.
  151. [11/90]
  152.  
  153. ----------------------------------------------------------------------
  154. Subject: 114)  Why don't XtConfigureWidget/XtResizeWidget/XtMoveWidget work?
  155.  
  156.     You're probably trying to use these functions from application code.
  157. They should be used only internally to widgets; these functions are for a 
  158. parent widget to change the geometry of its children. Other promising 
  159. functions, XtMakeGeometryRequest() and XtMakeResizeRequest(), are also for use 
  160. only by widgets, in this case by a child to request a change from its parent.
  161.     The only way for your application to request a geometry change for a
  162. widget is to issue an XtSetValues call setting some of the geometry resources.
  163. Although this will result in the widget-internal functions' being called, your
  164. application code must use the standard XtSetValues interface or risk the 
  165. widgets' data becoming corrupted.
  166.     [The Xlib calls XMoveWindow() and XResizeWindow() should similarly be 
  167. avoided; they shouldn't be used to change XtNx, XtNy, XtNwidth, or XtNheight.]
  168.  
  169. ----------------------------------------------------------------------
  170. Subject: 115)  Why isn't there an XtReparentWidget call like XReparentWindow?
  171.  
  172.     Although there are various details of the current implementation of
  173. the Xt internals which make reparenting difficult, the major reason that no
  174. such call exists is that it remains undefined what the set of resources for
  175. the "new" widget should be. Resources are typically set based on the location
  176. in the instance hierarchy; what resources should change if the instance moves?
  177. What should happen to the widget's children? And by the time such semantics are
  178. defined, there would probably be little advantage over destroying the old 
  179. widget and creating a new widget in the correct location with the desired 
  180. resources, as setting the resources correctly is the majority of work in 
  181. creating a new widget.
  182.  
  183.     Note that reparenting is possible in the OI toolkit.
  184.  
  185. ----------------------------------------------------------------------
  186. Subject: 116)  I'm writing a widget and can't use a float as a resource value.
  187.  
  188. Float resources are not portable; the size of the value may be larger than
  189. the size of an XtPointer. Try using a pointer to a float instead; the Xaw
  190. Scrollbar float resources are handled in this way. 
  191.  
  192. ----------------------------------------------------------------------
  193. Subject: 117)  Is this a memory leak in the X11R4 XtDestroyWidget()?!
  194.  
  195. Yes. This is the "unofficial" fix-19 for the X11R4 Destroy.c:
  196.  
  197. *** Destroy.c.1.37    Thu Jul 11 15:41:25 1991
  198. --- lib/Xt/Destroy.c    Thu Jul 11 15:42:23 1991
  199. ***************
  200. *** 1,4 ****
  201. --- 1,5 ----
  202.   /* $XConsortium: Destroy.c,v 1.37 90/09/28 10:21:32 swick Exp $ */
  203. + /* Plus unofficial patches in revisions 1.40 and 1.41 */
  204.   
  205.   /***********************************************************
  206.   Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  207. ***************
  208. *** 221,239 ****
  209.        */
  210.   
  211.       int i = 0;
  212. !     DestroyRec* dr = app->destroy_list;
  213.       while (i < app->destroy_count) {
  214.       if (dr->dispatch_level >= dispatch_level)  {
  215.           Widget w = dr->widget;
  216.           if (--app->destroy_count)
  217.           bcopy( (char*)(dr+1), (char*)dr,
  218. !                app->destroy_count*sizeof(DestroyRec)
  219.                 );
  220.           XtPhase2Destroy(w);
  221.       }
  222.       else {
  223.           i++;
  224. -         dr++;
  225.       }
  226.       }
  227.   }
  228. --- 222,245 ----
  229.        */
  230.   
  231.       int i = 0;
  232. !     DestroyRec* dr;
  233.       while (i < app->destroy_count) {
  234. +     /* XtPhase2Destroy can result in calls to XtDestroyWidget,
  235. +      * and these could cause app->destroy_list to be reallocated.
  236. +      */
  237. +     dr = app->destroy_list + i;
  238.       if (dr->dispatch_level >= dispatch_level)  {
  239.           Widget w = dr->widget;
  240.           if (--app->destroy_count)
  241.           bcopy( (char*)(dr+1), (char*)dr,
  242. !                (app->destroy_count - i) * sizeof(DestroyRec)
  243.                 );
  244.           XtPhase2Destroy(w);
  245.       }
  246.       else {
  247.           i++;
  248.       }
  249.       }
  250.   }
  251.  
  252. [from Donna Converse, converse@expo.lcs.mit.EDU]
  253.  
  254. ----------------------------------------------------------------------
  255. Subject: 118)  Are callbacks guaranteed to be called in the order registered?
  256.  
  257.     Although some books demonstrate that the current implementation of Xt
  258. happens to call callback procedures in the order in which they are registered, 
  259. the specification does not guarantee such a sequence, and supplemental 
  260. authoritative documents (i.e. the Asente/Swick volume) do say that the order is
  261. undefined.  Because the callback list can be manipulated by both the widget and
  262. the application, Xt cannot guarantee the order of execution.
  263.     In general, the callback procedures should be thought of as operating 
  264. independently of one another and should not depend on side-effects of other
  265. callbacks operating; if a seqence is needed, then the single callback to be 
  266. registered can explicitly call other functions necessary.
  267.  
  268. [4/92; thanks to converse@expo.lcs.mit.edu]
  269.  
  270. ----------------------------------------------------------------------
  271. Subject: 119)  Why doesn't XtDestroyWidget() actually destroy the widget?
  272.  
  273.     XtDestroyWidget() operates in two passes, in order to avoid leaving
  274. dangling data structures; the function-call marks the widget, which is not 
  275. actually destroyed until your program returns to its event-loop. 
  276.  
  277. ----------------------------------------------------------------------
  278. Subject: 120)  How do I query the user synchronously using Xt?
  279.     
  280.     It is possible to have code which looks like this trivial callback,
  281. which has a clear flow of control. The calls to AskUser() block until answer
  282. is set to one of the valid values. If it is not a "yes" answer, the code drops
  283. out of the callback and back to an event-processing loop: 
  284.  
  285.     void quit(Widget w, XtPointer client, XtPointer call)
  286.     {
  287.         int             answer;
  288.         answer = AskUser(w, "Really Quit?");
  289.         if (RET_YES == answer)
  290.             {
  291.             answer = AskUser(w, "Are You Really Positive?");
  292.             if (RET_YES == answer)
  293.                 exit(0);
  294.                 }
  295.     }
  296.  
  297.     A more realistic example might ask whether to create a file or whether 
  298. to overwrite it.
  299.     This is accomplished by entering a second event-processing loop and
  300. waiting until the user answers the question; the answer is returned to the
  301. calling function. That function AskUser() looks something like this, where the 
  302. Motif can be replaced with widget-set-specific code to create some sort of 
  303. dialog-box displaying the question string and buttons for "OK", "Cancel" and 
  304. "Help" or equivalents:
  305.  
  306.   int AskUser(w, string)
  307.         Widget          w;
  308.         char           *string;
  309.   {
  310.         int             answer=RET_NONE;    /* some not-used marker */
  311.         Widget          dialog;            /* could cache&carry, but ...*/
  312.         Arg             args[3];
  313.         int             n = 0;
  314.         XtAppContext    context;
  315.  
  316.         n=0;
  317.         XtSetArg(args[n], XmNmessageString, XmStringCreateLtoR(string,
  318.                 XmSTRING_DEFAULT_CHARSET)); n++;
  319.         XtSetArg(args[n], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); n++;
  320.         dialog = XmCreateQuestionDialog(XtParent(w), string, args, n);
  321.         XtAddCallback(dialog, XmNokCallback, response, &answer);
  322.         XtAddCallback(dialog, XmNcancelCallback, response, &answer);
  323.         XtAddCallback(dialog, XmNhelpCallback, response, &answer);
  324.         XtManageChild(dialog);
  325.  
  326.         context = XtWidgetToApplicationContext (w);
  327.         while (answer == RET_NONE || XtAppPending(context)) {
  328.                 XtAppProcessEvent (context, XtIMAll);
  329.         }
  330.         XtDestroyWidget(dialog);  /* blow away the dialog box and shell */
  331.         return answer;
  332.   }
  333.  
  334.     The dialog supports three buttons, which are set to call the same 
  335. function when tickled by the user.  The variable answer is set when the user 
  336. finally selects one of those choices:
  337.  
  338.   void response(w, client, call)
  339.         Widget          w;
  340.         XtPointer client;
  341.         XtPointer call;
  342.   {
  343.   int *answer = (int *) client;
  344.   XmAnyCallbackStruct *reason = (XmAnyCallbackStruct *) call;
  345.         switch (reason->reason) {
  346.         case XmCR_OK:
  347.                 *answer = RET_YES;    /* some #define value */
  348.                 break;
  349.         case XmCR_CANCEL:
  350.                 *answer = RET_NO; 
  351.         break;
  352.         case XmCR_HELP:
  353.                 *answer = RET_HELP;
  354.                 break;
  355.         default:
  356.                 return;
  357.         }
  358. }
  359.  
  360. and the code unwraps back to the point at which an answer was needed and
  361. continues from there.
  362.  
  363. [Thanks to Dan Heller (argv@sun.com); further code is in Dan's R3/contrib
  364. WidgetWrap library. 2/91]
  365.  
  366. ----------------------------------------------------------------------
  367. Subject: 121)  How do I determine the name of an existing widget?
  368. I have a widget ID and need to know what the name of that widget is.
  369.  
  370.     Users of R4 and later are best off using the XtName() function, which 
  371. will work on both widgets and non-widget objects.
  372.  
  373.     If you are still using R3, you can use this simple bit of code to do 
  374. what you want. Note that it depends on the widget's internal data structures 
  375. and is not necessarily portable to future versions of Xt, including R4.
  376.  
  377.     #include <X11/CoreP.h>
  378.     #include <X11/Xresource.h>
  379.     String XtName (widget)
  380.     Widget widget;    /* WILL work with non-widget objects */
  381.     {
  382.     return XrmNameToString(widget->core.xrm_name);
  383.     }
  384.  
  385. [7/90; modified with suggestion by Larry Rogers (larry@boris.webo.dg.com) 9/91]
  386.  
  387. ----------------------------------------------------------------------
  388. Subject: 122)  What widget is appropriate to use as a drawing canvas?
  389.  
  390.     Some widget sets have a widget particularly for this purpose -- a
  391. WorkSpace or DrawingArea which doesn't display anything but lets your Xt 
  392. application know when it has been re-exposed, resized, and when it has received
  393. user key and mouse input. 
  394.     The best thing to do for other widget sets -- including the Athena set 
  395. -- is to create or obtain such a widget; this is preferable to drawing into a 
  396. core widget and grabbing events with XtAddEventHandler(), which loses a number 
  397. of benefits of Xt and encapsulation of the functionality .  At least one 
  398. version has been posted to comp.sources.x (name???). The publicly-available 
  399. programs xball and xpic include other versions. And the Athena Widget manual 
  400. (mit/doc/Xaw/Template in the R5 distribution) includes a tutorial and source 
  401. code to a simple widget which is suitable for use.
  402.  
  403. ----------------------------------------------------------------------
  404. Subject: 123)  Why do I get a BadDrawable error drawing to XtWindow(widget)?
  405. I'm doing this in order to get a window into which I can do Xlib graphics
  406. within my Xt-based program:
  407.  
  408. > canvas = XtCreateManagedWidget ( ...,widgetClass,...) /* drawing area */
  409. > ...
  410. > window = XtWindow(canvas);    /* get the window associated with the widget */
  411. > ...
  412. > XDrawLine (...,window,...);    /* produces error */
  413.  
  414.     The window associated with the widget is created as a part of the 
  415. realization of the widget.  Using a window id of NULL ("no window") could 
  416. create the error that you describe.  It is necessary to call XtRealizeWidget() 
  417. before attempting to use the window associated with a widget. 
  418.     Note that the window will be created after the XtRealizeWidget() call, 
  419. but that the server may not have actually mapped it yet, so you should also 
  420. wait for an Expose event on the window before drawing into it.
  421.  
  422. ----------------------------------------------------------------------
  423. Subject: 124)  Why do I get a BadMatch error when calling XGetImage?
  424.  
  425. The BadMatch error can occur if the specified rectangle goes off the edge of 
  426. the screen. If you don't want to catch the error and deal with it, you can take
  427. the following steps to avoid the error:
  428.  
  429. 1) Make a pixmap the same size as the rectangle you want to capture.
  430. 2) Clear the pixmap to background using XFillRectangle.
  431. 3) Use XCopyArea to copy the window to the pixmap.
  432. 4) If you get a NoExpose event, the copy was clean. Use XGetImage to grab the
  433. image from the pixmap.
  434. 5) If you get one or more GraphicsExpose events, the copy wasn't clean, and 
  435. the x/y/width/height members of the GraphicsExpose event structures tell you 
  436. the parts of the pixmap which aren't good.
  437. 6) Get rid of the pixmap; it probably takes a lot of memory.
  438.  
  439. [10/92; thanks to Oliver Jones (oj@pictel.com)]
  440.  
  441. ----------------------------------------------------------------------
  442. Subject: 125)  How can my application tell if it is being run under X?
  443.  
  444.     A number of programs offer X modes but otherwise run in a straight
  445. character-only mode. The easiest way for an application to determine that it is
  446. running on an X display is to attempt to open a connection to the X server:
  447.     
  448.     display = XOpenDisplay(display_name);
  449.     if (display)
  450.         { do X stuff }
  451.     else
  452.         { do curses or something else }
  453. where display_name is either the string specified on the command-line following
  454. -display, by convention, or otherwise is (char*)NULL [in which case 
  455. XOpenDisplay uses the value of $DISPLAY, if set].
  456.  
  457. This is superior to simply checking for the existence a -display command-line 
  458. argument or checking for $DISPLAY set in the environment, neither of which is 
  459. adequate. [5/91]
  460.  
  461. ----------------------------------------------------------------------
  462. Subject: 126)! How do I make a "busy cursor" while my application is computing?
  463. Is it necessary to call XDefineCursor() for every window in my application?
  464.  
  465.     The easiest thing to do is to create a single InputOnly window that is 
  466. as large as the largest possible screen; make it a child of your toplevel 
  467. window and it will be clipped to that window, so it won't affect any other 
  468. application. (It needs to be as big as the largest possible screen in case the 
  469. user enlarges the window while it is busy or moves elsewhere within a virtual 
  470. desktop.) Substitute "toplevel" with your top-most widget here (similar code 
  471. should work for Xlib-only applications; just use your top Window):
  472.  
  473.      unsigned long valuemask;
  474.      XSetWindowAttributes attributes;
  475.  
  476.      /* Ignore device events while the busy cursor is displayed. */
  477.      valuemask = CWDontPropagate | CWCursor;
  478.      attributes.do_not_propagate_mask =  (KeyPressMask | KeyReleaseMask |
  479.          ButtonPressMask | ButtonReleaseMask | PointerMotionMask);
  480.      attributes.cursor = XCreateFontCursor(XtDisplay(toplevel), XC_watch);
  481.  
  482.      /* The window will be as big as the display screen, and clipped by
  483.         its own parent window, so we never have to worry about resizing */
  484.      XCreateWindow(XtDisplay(toplevel), XtWindow(toplevel), 0, 0,
  485.          65535, 65535, (unsigned int) 0, CopyFromParent, InputOnly,
  486.          CopyFromParent, valuemask, &attributes);
  487.  
  488. where the maximum size above could be replaced by the real size of the screen,
  489. particularly to avoid servers which have problems with windows larger than
  490. 32767.
  491.  
  492. When you want to use this busy cursor, map and raise this window; to go back to
  493. normal, unmap it. This will automatically keep you from getting extra mouse
  494. events; depending on precisely how the window manager works, it may or may not
  495. have a similar effect on keystrokes as well.
  496.  
  497. In addition, note also that most of the Xaw widgets support an XtNcursor 
  498. resource which can be temporarily reset, should you merely wish to change the
  499. cursor without blocking pointer events.
  500.  
  501. [thanks to Andrew Wason (aw@cellar.bae.bellcore.com), Dan Heller 
  502. (argv@sun.com), and mouse@larry.mcrcim.mcgill.edu; 11/90,5/91]
  503.  
  504. ----------------------------------------------------------------------
  505. Subject: 127)  How do I fork without hanging my parent X program?
  506.  
  507.     An X-based application which spawns off other Unix processes which 
  508. continue to run after it is closed typically does not vanish until all of its 
  509. children are terminated; the children inherit from the parent the open X 
  510. connection to the display. 
  511.     What you need to do is fork; then, immediately, in the child process, 
  512.     close (ConnectionNumber(XtDisplay(widget)));
  513. to close the file-descriptor in the display information. After this do your 
  514. exec. You will then be able to exit the parent.
  515.  
  516. [Thanks to Janet Anstett (anstettj@tramp.Colorado.EDU) and Gordon Freedman 
  517. (gjf00@duts.ccc.amdahl.com) 2/91]
  518.  
  519. ----------------------------------------------------------------------
  520. Subject: 128)  Can I make Xt or Xlib calls from a signal handler?
  521.  
  522.     No. Xlib and Xt have no mutual exclusion for protecting critical 
  523. sections. If your signal handler makes such a call at the wrong time (which 
  524. might be while the function you are calling is already executing), it can leave
  525. the library in an inconsistent state. Note that the ANSI C standard points
  526. out that behavior of a signal handler is undefined if the signal handler calls
  527. any function other than signal() itself, so this is not a problem specific to
  528. Xlib and Xt; the POSIX specification mentions other functions which may be
  529. called safely but it may not be assumed that these functions are called by 
  530. Xlib or Xt functions.
  531.     You can work around the problem by setting a flag in the interrupt
  532. handler and later checking it with a work procedure or a timer event which
  533. has previously been added.
  534.  
  535.     Note: the article in The X Journal 1:4 and the example in O'Reilly 
  536. Volume 6 are in error.
  537.  
  538. [Thanks to Pete Ware (ware@cis.ohio-state.edu) and Donna Converse 
  539. (converse@expo.lcs.mit.EDU), 5/92]
  540.  
  541. ----------------------------------------------------------------------
  542. Subject: 129)  What are these "Xlib sequence lost" errors?
  543.  
  544.     You may see these errors if you issue Xlib requests from an Xlib error 
  545. handler, or, more likely, if you make calls which generate X requests to Xt or 
  546. Xlib from a signal handler, which you shouldn't be doing in any case. 
  547.  
  548. ----------------------------------------------------------------------
  549. Subject: 130)  How can my Xt program handle socket, pipe, or file input?
  550.  
  551.     It's very common to need to write an Xt program that can accept input 
  552. both from a user via the X connection and from some other file descriptor, but 
  553. which operates efficiently and without blocking on either the X connection or 
  554. the other file descriptor.
  555.     A solution is use XtAppAddInput(). After you open your file descriptor, 
  556. use XtAppAddInput() to register an input handler. The input handler will be 
  557. called every time there is something on the file descriptor requiring your 
  558. program's attention. Write the input handler like you would any other Xt 
  559. callback, so it does its work quickly and returns.  It is important to use only 
  560. non-blocking I/O system calls in your input handlers.
  561.     Most input handlers read the file descriptor, although you can have an 
  562. input handler write or handle exception conditions if you wish.
  563.     Be careful when you register an input handler to read from a disk file.
  564. You will find that the function is called even when there isn't input pending.
  565. XtAppAddInput() is actually working as it is supposed to. The input handler is 
  566. called whenever the file descriptor is READY to be read, not only when there is
  567. new data to be read. A disk file (unlike a pipe or socket) is almost always 
  568. ready to be read, however, if only because you can spin back to the beginning
  569. and read data you've read before.  The result is that your function will almost
  570. always be called every time around XtAppMainLoop(). There is a way to get the 
  571. type of interaction you are expecting; add this line to the beginning of your 
  572. function to test whether there is new data:
  573.          if (ioctl(fd, FIONREAD, &n) == -1 || n == 0) return;
  574. But, because this is called frequently, your application is effectively in a 
  575. busy-wait; you may be better off not using XtAppAddInput() and instead setting 
  576. a timer and in the timer procedure checking the file for input.
  577.  
  578. [courtesy Dan Heller (argv@ora.com), 8/90; mouse@larry.mcrcim.mcgill.edu 5/91;
  579. Ollie Jones (oj@pictel.com) 6/92]
  580.  
  581. ----------------------------------------------------------------------
  582. Subject: 131)  How do I simulate a button press/release event for a widget?
  583.  
  584.     You can do this using XSendEvent(); it's likely that you're not setting
  585. the window field in the event, which Xt needs in order to match to the widget
  586. which should receive the event.
  587.      If you're sending events to your own application, then you can use 
  588. XtDispatchEvent() instead. This is more efficient than XSendEvent() in that you
  589. avoid a round-trip to the server.
  590.     Depending on how well the widget was written, you may be able to call
  591. its action procedures in order to get the effects you want.
  592.  
  593. [courtesy Mark A. Horstman (mh2620@sarek.sbc.com), 11/90]
  594.  
  595. ----------------------------------------------------------------------
  596. Subject: 132)  Why doesn't anything appear when I run this simple program?
  597.  
  598. > ...
  599. > the_window = XCreateSimpleWindow(the_display,
  600. >      root_window,size_hints.x,size_hints.y,
  601. >      size_hints.width,size_hints.height,BORDER_WIDTH,
  602. >      BlackPixel(the_display,the_screen),
  603. >      WhitePixel(the_display,the_screen));
  604. > ...
  605. > XSelectInput(the_display,the_window,ExposureMask|ButtonPressMask|
  606. >     ButtonReleaseMask);
  607. > XMapWindow(the_display,the_window);
  608. > ...
  609. > XDrawLine(the_display,the_window,the_GC,5,5,100,100);
  610. > ...
  611.  
  612.     You are right to map the window before drawing into it. However, the 
  613. window is not ready to be drawn into until it actually appears on the screen --
  614. until your application receives an Expose event. Drawing done before that will 
  615. generally not appear. You'll see code like this in many programs; this code 
  616. would appear after window was created and mapped:
  617.   while (!done)
  618.     {
  619.       XNextEvent(the_display,&the_event);
  620.       switch (the_event.type) {
  621.     case Expose:     /* On expose events, redraw */
  622.         XDrawLine(the_display,the_window,the_GC,5,5,100,100);
  623.         break;
  624.     ...
  625.     }
  626.     }
  627.  
  628.     Note that there is a second problem: some Xlib implementations don't 
  629. set up the default graphics context to have correct foreground/background 
  630. colors, so this program could previously include this code:
  631.   ...
  632.   the_GC_values.foreground=BlackPixel(the_display,the_screen);    /* e.g. */
  633.   the_GC_values.background=WhitePixel(the_display,the_screen);    /* e.g. */
  634.   the_GC = XCreateGC(the_display,the_window,
  635.                 GCForeground|GCBackground,&the_GC_values);
  636.   ...
  637.  
  638. Note: the code uses BlackPixel and WhitePixel to avoid assuming that 1 is 
  639. black and 0 is white or vice-versa.  The relationship between pixels 0 and 1 
  640. and the colors black and white is implementation-dependent.  They may be 
  641. reversed, or they may not even correspond to black and white at all.
  642.  
  643. Also note that actually using BlackPixel and WhitePixel is usually the wrong 
  644. thing to do in a finished program, as it ignores the user's preference for 
  645. foreground and background.
  646.  
  647. And also note that you can run into the same situation in an Xt-based program
  648. if you draw into the XtWindow(w) right after it has been realized; it may
  649. not yet have appeared.
  650.  
  651. ----------------------------------------------------------------------
  652. Subject: 133)  What is the difference between a Screen and a screen?
  653.  
  654.     The 'Screen' is an Xlib structure which includes the information about
  655. one of the monitors or virtual monitors which a single X display supports. A 
  656. server can support several independent screens. They are numbered unix:0.0,
  657. unix:0.1, unix:0.2, etc; the 'screen' or 'screen_number' is the second digit --
  658. the 0, 1, 2 which can be thought of as an index into the array of available 
  659. Screens on this particular Display connection.
  660.     The macros which you can use to obtain information about the particular
  661. Screen on which your application is running typically have two forms -- one
  662. which takes a Screen and one with takes both the Display and the screen_number.
  663.     In Xt-based programs, you typically use XtScreen(widget) to determine 
  664. the Screen on which your application is running, if it uses a single screen.
  665.     (Part of the confusion may arise from the fact that some of the macros
  666. which return characteristics of the Screen have "Display" in the names -- 
  667. XDisplayWidth, XDisplayHeight, etc.)
  668.     
  669. ----------------------------------------------------------------------
  670. Subject: 134)  Can I use C++ with X11? Motif? XView?
  671.     
  672.     The X11R4/5 header files are compatible with C++. The Motif 1.1 header 
  673. files are usable as is inside extern "C" {...}. However, the definition of
  674. String in Intrinsic.h can conflict with the libg++ or other String class and
  675. needs to be worked around.
  676.  
  677.     Some other projects which can help:
  678.     WWL, a set of C++ classes by Jean-Daniel Fekete to wrap X Toolkit 
  679. widgets, available via anonymous FTP from export.lcs.mit.edu as 
  680. contrib/WWL-1.2.tar.Z [7/92] or lri.lri.fr (129.175.15.1) as pub/WWL-1.2.tar.Z.
  681. It works by building a set of C++ classes in parallel to the class tree of the 
  682. widgets.
  683.     The C++ InterViews toolkit is obtainable via anonymous FTP from 
  684. interviews.stanford.edu. InterViews uses a box/glue model similar to that of 
  685. TeX for constructing user interfaces and supports multiple looks on the user 
  686. interfaces. Some of its sample applications include a WYSIWIG document editor 
  687. (doc), a MacDraw-like drawing program (idraw) and an interface builder (ibuild).
  688.     THINGS,  a class library written at the Rome Air Force Base by the 
  689. Strategic Air Command, available as freeware on archive sites.
  690.  
  691.     Motif++ is a public-domain library that defines C++ class wrappers for
  692. Motif 1.1; it adds an "application" class for, e.g., initializing X, and also
  693. integrates WCL and the Xbae widget set. This work was developed by Ronald van 
  694. Loon <rvloon@cv.ruu.nl> based on X++, a set of bindings done by the University 
  695. of Lowell Graphics Research Laboratory. The current sources are available from 
  696. decuac.dec.com (192.5.214.1) as /pub/X11/motif++.21.jul.92.tar.Z.
  697.     
  698.     The source code examples for Doug Young's "Object-Oriented Programming 
  699. with C++ and OSF/Motif" [ISBN 0-13-630252-1] do not include "widget wrappers" 
  700. but do include a set of classes that encapsulates higher-level facilities 
  701. commonly needed by Motif- or other Xt-based applications; check export in
  702. ~ftp/contrib/young.c++.tar.Z.
  703.     Rogue Wave offers "View.h++" for C++ programmers using Motif; info:
  704. 1-800-487-3217 or +1 503 754 2311.
  705.     A product called "Commonview" by Glockenspiel Ltd, Ireland (??) 
  706. apparently is a C++-based toolkit for multiple window systems, including PM,
  707. Windows, and X/Motif.
  708.     Xv++ is sold by Qualix (415-572-0200; fax -1300); it implements an 
  709. interface from the GIL files that Sun's OpenWindows Developers Guide 3.0 
  710. produces to Xview wrapper classes in C++.
  711.  
  712.     UIT is a set of C++ classes embedding the XView toolkit; it is intended
  713. for use with Sun's OpenWindows Developers Guide 3.0 builder tool. Sources are 
  714. on export.mit.edu.au as UIT.tar.Z. Version 2 was released 5/28/92.
  715.     
  716.     Also of likely use is ObjectCenter (Saber-C++). And a reasonable
  717. alternative to all of the above is ParcPlace's (formerly Solbourne's) Object 
  718. Interface.
  719.  
  720. [Thanks to Douglas S. Rand (dsrand@mitre.org) and George Wu (gwu@tcs.com);2/91]
  721.  
  722. ----------------------------------------------------------------------
  723. Subject: 135)! Where can I obtain alternate language bindings to X?
  724.  
  725.     Versions of the CLX Lisp bindings are part of the X11 core source 
  726. distributions. A version of CLX is on the R5 tape [10/91]; version 5.0.2 [9/92]
  727. is on export.lcs.mit.edu in /contrib/CLX.R5.02.tar.Z.
  728.  
  729.     The SAIC Ada-X11 bindings are through anonymous ftp in /pub from
  730. stars.rosslyn.unisys.com (128.126.164.2). 
  731.     There is an X/Ada study team sponsored by NASA JSC, which apparently is
  732. working out bindings. Information: xada@ghg.hou.tx.us.
  733.     GNU SmallTalk has a beta native SmallTalk binding to X called STIX (by
  734. Steven.Byrne@Eng.Sun.COM). It is still in its beginning stages, and 
  735. documentation is sparse outside the SmallTalk code itself. The sources are 
  736. available as /pub/gnu/smalltalk-1.1.1.tar.Z on prep.ai.mit.edu (18.71.0.38) or 
  737. ugle.unit.no (129.241.1.97).
  738.     Prolog bindings (called "XWIP") written by Ted Kim at UCLA while
  739. supported in part by DARPA are available by anonymous FTP from
  740. export.lcs.mit.edu:contrib/xwip.tar.Z or ftp.cs.ucla.edu:pub/xwip.tar.Z.
  741. These prolog language bindings depend on having a Quintus-type foreign function
  742. interface in your prolog. The developer has gotten it to work with Quintus and 
  743. SICStus prolog. Inquiries should go to xwip@cs.ucla.edu. [3/90]
  744.     Scheme bindings to Xlib, OSF/Motif, and Xaw are part of the Elk
  745. distribution; version 1.5a on export obsoletes the version on the R5 contrib
  746. tape. 
  747.     x-scm, a bolt-on accessory for Aubrey Jaffer's "scm" Scheme interpreter
  748. that provides an interface to Xlib, Motif, and OpenLook, is now available via 
  749. FTP from altdorf.ai.mit.edu:archive/scm/xscm1.05.tar.Z and 
  750. nexus.yorku.ca:pub/scheme/new/xscm1.05.tar.Z.
  751.  
  752.     Ada bindings to Motif, explicitly, will eventually be made available by
  753. the Jet Propulsion Laboratories, probably through the normal electronic
  754. means.  Advance information can be obtained from dsouleles@dsfvax.jpl.nasa.gov,
  755. who may respond as time permits.
  756.     AdaMotif is a complete binding to X and Motif for the Ada language, for
  757. many common systems; it is based in part upon the SAIC/Unisys bindings and also
  758. includes a UIL to Ada translator. Info: Systems Engineering Research 
  759. Corporation, 1-800-Ada-SERC (well!serc@apple.com).
  760.  
  761.     Also: the MIT Consortium, although not involved in producing Ada
  762. bindings for X, maintains a partial listing of people involved in X and Ada;
  763. information is available from Donna Converse, converse@expo.lcs.mit.edu.
  764.  
  765. ----------------------------------------------------------------------
  766. Subject: 136)  Can XGetWindowAttributes get a window's background pixel/pixmap?
  767.  
  768.     No.  Once set, the background pixel or pixmap of a window cannot be 
  769. re-read by clients.  The reason for this is that a client can create a pixmap,
  770. set it to be the background pixmap of a window, and then free the pixmap. The 
  771. window keeps this background, but the pixmap itself is destroyed.  If you're 
  772. sure a window has a background pixel (not a pixmap), you can use XClearArea() 
  773. to clear a region to the background color and then use XGetImage() to read 
  774. back that pixel.  However, this action alters the contents of the window, and 
  775. it suffers from race conditions with exposures. [courtesy Dave Lemke of NCD 
  776. and Stuart Marks of Sun]
  777.  
  778.     Note that the same applies to the border pixel/pixmap. This is a 
  779. (mis)feature of the protocol which allows the server is free to manipulate the
  780. pixel/pixmap however it wants.  By not requiring the server to keep the 
  781. original pixel or pixmap, some (potentially a lot of) space can be saved. 
  782. [courtesy Jim Fulton, MIT X Consortium]
  783.  
  784. ----------------------------------------------------------------------
  785. Subject: 137)  How do I create a transparent window?
  786.     
  787.     A completely transparent window is easy to get -- use an InputOnly
  788. window. In order to create a window which is *mostly* transparent, you have
  789. several choices:
  790.     - the SHAPE extension first released with X11R4 offers an easy way to
  791. make non-rectangular windows, so you can set the shape of the window to fit the
  792. areas where the window should be nontransparent; however, not all servers 
  793. support the extension.
  794.     - a machine-specific method of implementing transparent windows for
  795. particular servers is to use an overlay plane supported by the hardware.  Note 
  796. that there is no X notion of a "transparent color index".
  797.     - a generally portable solution is to use a large number of tiny 
  798. windows, but this makes operating on the application as a unit difficult.
  799.     - a final answer is to consider whether you really need a transparent
  800. window or if you would be satisfied with being able to overlay your application
  801. window with information; if so, you can draw into separate bitplanes in colors
  802. that will appear properly.
  803.  
  804. [thanks to der Mouse, mouse@lightning.McRCIM.McGill.EDU, 3/92; see also
  805. The X Journal 1:4 for a more complete answer, including code samples for this
  806. last option]
  807.  
  808. ----------------------------------------------------------------------
  809. Subject: 138)  Why doesn't GXxor produce mathematically-correct color values?
  810.  
  811.     When using GXxor you may expect that drawing with a value of black on a
  812. background of black, for example, should produce white. However, the drawing
  813. operation does not work on RGB values but on colormap indices. The color that
  814. the resulting colormap index actually points to is undefined and visually
  815. random unless you have actually filled it in yourself. [On many X servers Black
  816. and White often 0/1 or 1/0; programs taking advantage of this mathematical
  817. coincidence will break.]
  818.     If you want to be combining colors with GXxor, then you should be 
  819. allocating a number of your own color cells and filling them with your chosen
  820. pre-computed values.
  821.     If you want to use GXxor simply to switch between two colors, then you 
  822. can take the shortcut of setting the background color in the GC (graphics 
  823. context) to 0 and the foreground color to a value such that when it draws over 
  824. red, say, the result is blue, and when it draws over blue the result is red. 
  825. This foreground value is itself the XOR of the colormap indices of red and 
  826. blue.
  827.  
  828. [Thanks to Chris Flatters (cflatter@zia.aoc.nrao.EDU) and Ken Whaley 
  829. (whaley@spectre.pa.dec.com), 2/91]
  830.  
  831. ----------------------------------------------------------------------
  832. Subject: 139)  Why does every color I allocate show up as black?
  833.  
  834.     Make sure you're using 16 bits and not 8.  The red, green, and blue 
  835. fields of an XColor structure are scaled so that 0 is nothing and 65535 is 
  836. full-blast. If you forget to scale (using, for example, 0-255 for each color) 
  837. the XAllocColor function will perform correctly but the resulting color is 
  838. usually black. 
  839.  
  840. [Thanks to Paul Asente, asente@adobe.com, 7/91]
  841.  
  842. ----------------------------------------------------------------------
  843. Subject: 140)  Why can't my program get a standard colormap?
  844. I have an image-processing program which uses XGetRGBColormap() to get the 
  845. standard colormap, but it doesn't work. 
  846.  
  847.     XGetRGBColormap() when used with the property XA_RGB_DEFAULT_MAP does 
  848. not create a standard colormap -- it just returns one if one already exists.
  849. Use xstdcmap or do what it does in order to create the standard colormap first.
  850.  
  851. [1/91; from der Mouse (mouse@larry.mcrcim.mcgill.edu)]
  852.  
  853. ----------------------------------------------------------------------
  854. Subject: 141)  Why does the pixmap I copy to the screen show up as garbage? 
  855.  
  856.     The initial contents of pixmaps are undefined.  This means that most
  857. servers will allocate the memory and leave around whatever happens to be there 
  858. -- which is usually garbage.  You probably want to clear the pixmap first using
  859. XFillRectangle() with a function of GXcopy and a foreground pixel of whatever 
  860. color you want as your background (or 0L if you are using the pixmap as a 
  861. mask). [courtesy Dave Lemke of NCD and Stuart Marks of Sun]
  862.  
  863. ----------------------------------------------------------------------
  864. Subject: 142)  How do I check whether a window ID is valid?
  865. My program has the ID of a window on a remote display. I want to check whether
  866. the window exists before doing anything with it.
  867.  
  868.     Because X is asynchronous, there isn't a guarantee that the window 
  869. would still exist between the time that you got the ID and the time you sent an
  870. event to the window or otherwise manipulated it. What you should do is send the
  871. event without checking, but install an error handler to catch any BadWindow 
  872. errors, which would indicate that the window no longer exists. This scheme will
  873. work except on the [rare] occasion that the original window has been destroyed 
  874. and its ID reallocated to another window.
  875.  
  876. [courtesy Ken Lee (klee@wsl.dec.com), 4/90]
  877.  
  878. ----------------------------------------------------------------------
  879. Subject: 143)  Can I have two applications draw to the same window?
  880.  
  881.     Yes. The X server assigns IDs to windows and other resources (actually,
  882. the server assigns some bits, the client others), and any application that 
  883. knows the ID can manipulate the resource [almost any X server resource, except
  884. for GCs and private color cells, can be shared].
  885.     The problem you face is how to disseminate the window ID to multiple 
  886. applications. A simple way to handle this (and which solves the problem of the
  887. applications' running on different machines) is in the first application to 
  888. create a specially-named property on the root-window and put the window ID into 
  889. it. The second application then retrieves the property, whose name it also
  890. knows, and then can draw whatever it wants into the window.
  891.     [Note: this scheme works iff there is only one instance of the first
  892. application running, and the scheme is subject to the limitations mentioned
  893. in the Question about using window IDs on remote displays.]
  894.     Note also that you will still need to coordinate any higher-level 
  895. cooperation among your applications. 
  896.     Note also that two processes can share a window but should not try to 
  897. use the same server connection. If one process is a child of the other, it 
  898. should close down the connection to the server and open its own connection.
  899.  
  900. [mostly courtesy Phil Karlton (karlton@wpd.sgi.com) 6/90]
  901.  
  902. ----------------------------------------------------------------------
  903. Subject: 144)  Why can't my program work with tvtwm or swm?
  904.  
  905.     A number of applications, including xwd, xwininfo, and xsetroot, do not
  906. handle the virtual root window which tvtwm and swm use; they typically return 
  907. the wrong child of root. A general solution is to add this code or to use it in
  908. your own application where you would normally use RootWindow(dpy,screen):
  909.  
  910. /* Function Name: GetVRoot
  911.  * Description: Gets the root window, even if it's a virtual root
  912.  * Arguments: the display and the screen
  913.  * Returns: the root window for the client
  914.  */
  915. #include <X11/Xatom.h>
  916. Window GetVRoot(dpy, scr)
  917. Display        *dpy;
  918. int             scr;
  919. {
  920. Window          rootReturn, parentReturn, *children;
  921. unsigned int    numChildren;
  922. Window          root = RootWindow(dpy, scr);
  923. Atom            __SWM_VROOT = None;
  924. int             i;
  925.  
  926.   __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
  927.   XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren);
  928.   for (i = 0; i < numChildren; i++) {
  929.     Atom            actual_type;
  930.     int             actual_format;
  931.     long            nitems, bytesafter;
  932.     Window         *newRoot = NULL;
  933.  
  934.     if (XGetWindowProperty(dpy, children[i], __SWM_VROOT, 0, 1,
  935.         False, XA_WINDOW, &actual_type, &actual_format, &nitems,
  936.             &bytesafter, (unsigned char **) &newRoot) == Success && newRoot) {
  937.             root = *newRoot;
  938.             break;
  939.         }
  940.     }
  941.  
  942.     return root;
  943. }
  944.  
  945. [courtesy David Elliott (dce@smsc.sony.com). Similar code is in ssetroot, a
  946. version of xsetroot distributed with tvtwm. 2/91]
  947.  
  948. A header file by Andreas Stolcke of ICSI on export.lcs.mit.edu:contrib/vroot.h 
  949. functions similarly by providing macros for RootWindow and DefaultRootWindow;
  950. code can include this header file first to run properly in the presence of a
  951. virtual desktop.
  952.     
  953. ----------------------------------------------------------------------
  954. Subject: 145)  How do I keep a window from being resized by the user?
  955.  
  956.     Resizing the window is done through the window manager; window managers
  957. can pay attention to the size hints your application places on the window, but 
  958. there is no guarantee that the window manager will listen. You can try setting 
  959. the minimum and maximum size hints to your target size and hope for the best. 
  960. [1/91]
  961.  
  962. ----------------------------------------------------------------------
  963. Subject: 146)  How do I keep a window in the foreground at all times?
  964.  
  965.     It's rather antisocial for an application to constantly raise itself
  966. [e.g. by tracking VisibilityNotify events] so that it isn't overlapped -- 
  967. imagine the conflict between two such programs running.  
  968.     The only sure way to have your window appear on the top of the stack
  969. is to make the window override-redirect; this means that you are temporarily
  970. assuming window-management duties while the window is up, so you want to do 
  971. this infrequently and then only for short periods of time (e.g. for popup 
  972. menus or other short parameter-setting windows).
  973.  
  974. [thanks to der Mouse (mouse@larry.mcrcim.mcgill.edu); 7/92]
  975.  
  976. ----------------------------------------------------------------------
  977. Subject: 147)  How do I make text and bitmaps blink in X?
  978.  
  979.     There is no easy way.  Unless you're willing to depend on some sort of
  980. extension (as yet non-existent), you have to arrange for the blinking yourself,
  981. either by redrawing the contents periodically or, if possible, by playing games
  982. with the colormap and changing the color of the contents.
  983.  
  984. [Thanks to mouse@larry.mcrcim.mcgill.edu (der Mouse), 7/91]
  985.  
  986. ----------------------------------------------------------------------
  987. Subject: 148)  How do I render rotated text?
  988.     
  989.     Xlib intentionally does not provide such sophisticated graphics 
  990. capabilities, leaving them up to server-extensions or clients-side graphics
  991. libraries.
  992.     Your only choice, if you want to stay within the core X protocol, is to
  993. render the text into a pixmap, read it back via XGetImage(), rotate it "by 
  994. hand" with whatever matrices you want, and put it back to the server via 
  995. XPutImage(); more specifically:
  996.     1) create a bitmap B and write your text to it.
  997.     2) create an XYBitmap image I from B (via XGetImage).
  998.     3) create an XYBitmap Image I2 big enough to handle the transformation.
  999.     4) for each x,y in I2, I2(x,y) = I(a,b) where 
  1000.         a = x * cos(theta) - y * sin(theta)
  1001.         b = x * sin(theta) + y * cos(theta)
  1002.     5) render I2
  1003.     Note that you should be careful how you implement this not to lose
  1004. bits; an algorithm based on shear transformations may in fact be better.
  1005.     The high-level server-extensions and graphics packages available for X 
  1006. also permit rendering of rotated text: Display PostScript, PEX, PHiGS, and GKS,
  1007. although most are not capable of arbitrary rotation and probably do not use the
  1008. same fonts that would be found on a printer.
  1009.     In addition, if you have enough access to the server to install a font
  1010. on it, you can create a font which consists of letters rotated at some
  1011. predefined angle. Your application can then itself figure out placement of each
  1012. glyph.
  1013.  
  1014. [courtesy der Mouse (mouse@larry.mcrcim.mcgill.edu), Eric Taylor 
  1015. (etaylor@wilkins.bmc.tmc.edu), and Ken Lee (klee@wsl.dec.com), 11/90;
  1016. Liam Quin (lee@sq.com), 12/90]
  1017.  
  1018.     InterViews (C++ UI toolkit, in the X contrib software) has support for
  1019. rendering rotated fonts in X.  It could be one source of example code.
  1020. [Brian R. Smith (brsmith@cs.umn.edu), 3/91]
  1021.     Another possibility is to use the Hershey Fonts; they are 
  1022. stroke-rendered and can be used by X by converting them into XDrawLine 
  1023. requests. [eric@pencom.com, 10/91]
  1024.  
  1025.     The xrotfont program by Alan Richardson (mppa3@syma.sussex.ac.uk) 
  1026. (posted to comp.sources.x July 14 1992) paints a rotated font by implementing 
  1027. the method above and by using an outline (Hershey) font.
  1028.  
  1029.     O'Reilly's X Resource Volume 3 includes information from HP about
  1030. modifications to the X fonts server which provide for rotated and scaled text.
  1031.  
  1032. ----------------------------------------------------------------------
  1033. Subject: 149)  What is the X Registry? (How do I reserve names?)
  1034.  
  1035.     There are places in the X Toolkit, in applications, and in the X
  1036. protocol that define and use string names. The context is such that conflicts
  1037. are possible if different components use the same name for different things.
  1038.     The MIT X Consortium maintains a registry of names in these domains:
  1039. orgainization names, selection names, selection targets, resource types,
  1040. application classes, and class extension record types; and several others.
  1041.     The list as of 7/91 is in the directory mit/doc/Registry on the R5 
  1042. tape; it is also available by sending "send docs registry" to the xstuff mail
  1043. server.
  1044.     To register names (first come, first served) or to ask questions send 
  1045. to xregistry@expo.lcs.mit.edu; be sure to include a postal address for
  1046. confirmation.
  1047.  
  1048. [11/90; condensed from Asente/Swick Appendix H]
  1049. ----------------------------------------------------------------------
  1050.  
  1051. David B. Lewis                     faq%craft@uunet.uu.net
  1052.  
  1053.         "Just the FAQs, ma'am." -- Joe Friday 
  1054. -- 
  1055. David B. Lewis        Temporarily at but not speaking for Visual, Inc.
  1056. day: dbl@visual.com    evening: david%craft@uunet.uu.net
  1057.